<?php
$acao = "insert";
$titulo = "Novo ";
$required = "required";

if (isset($_POST["descricao"])) {
    $acao = "update";
    $titulo = "Editar ";
    $required = "";
}
?>
<div class="mws-panel grid_4 div-center">
    <div class="mws-panel-header">
        <span class="mws-i-24 i-list"><?php echo $titulo; ?>tipo de saída</span>
    </div>
    <div class="mws-panel-body">
        <div id="result"></div>

        <form action="<?php echo BASE_URL; ?>tiposaida/<?php echo $acao; ?>" enctype="multipart/form-data" name="tiposaida" method="POST" onsubmit="return __validaForm();" class="mws-form">
            <div class="mws-form-inline">
                <div class="mws-form-row">
                    <label>Descrição</label>
                    <div class="mws-form-item small">
                        <input type="text" name="descricao" id="descricao" class="mws-textinput required" value="<?php
                        if (isset($_POST["descricao"])) {
                            echo $_POST["descricao"];
                        }
                        ?>"/>
                    </div>
                </div>

                <?php
                if (isset($_POST["imagem"])) {
                    ?>
                    <input type="hidden" value="<?php echo $_POST["imagem"]; ?>" name="imagemAnt">
                    <input type="hidden" value="<?php echo $_POST["codigo"]; ?>" name="codigo">
                    <div class="mws-form-row">
                        <label>Ícone atual</label>

                        <div class="mws-form-item large">
                            <img src="<?php echo BASE_URL; ?>uploads/<?php echo $_POST["imagem"] ?>" width="32" height="32">
                        </div>
                    </div>
                    <?php
                }
                ?>

                <div class="mws-form-row">
                    <?php
                    if (isset($_POST["imagem"])) {
                        echo "<label>Alterar ícone</label>";
                    } else {
                        echo "<label>Selecione um ícone</label>";
                    }
                    ?>
                    <div class="mws-form-item large fileinput-holder">
                        <input type="file" size="32" name="imagem" value="" class="<?php echo $required; ?>"/>
                        <label for="picture" class="error" generated="true" style="display:none"></label>
                    </div>
                </div>
            </div>
            <div class="mws-button-row">
                <input type="submit" id="salvar-tsaida" value="Salvar" class="mws-button green"/>
                <a href="<?php echo BASE_URL; ?>tiposaida"><input type="button" value="Cancelar" class="mws-button gray" /></a>
            </div>

        </form>
    </div>    	
</div>